import 'dart:async';

import 'package:bloc/bloc.dart';
import 'package:equatable/equatable.dart';

part 'category_id_event.dart';
part 'category_id_state.dart';

//保存大类状态
class CategoryIdBloc extends Bloc<CategoryIdEvent, CategoryIdState> {
  int categoryId;

  CategoryIdBloc() : super(CategoryIdInitial(0));

  @override
  Stream<CategoryIdState> mapEventToState(
    CategoryIdEvent event,
  ) async* {
    if (event is SetCategoryIdEvent) {
      yield* _setMapEventToState(event);
    }
  }

  @override
  Stream<CategoryIdState> _setMapEventToState(
    SetCategoryIdEvent event,
  ) async* {
    this.categoryId = event.categoryId;
    yield CategoryIdChage(this.categoryId);
  }
}
